package day06;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/*
Collections：集合的工具类，提供了一些方法，方便操作列表和集合。
 */
public class Demo02 {

    public static void main(String[] args) {
        List<Integer> scores = Arrays.asList(10,80,67,88,45,53,66,77,95);

        int max = Collections.max(scores);
        System.out.println("最大值：" + max);

        int min = Collections.min(scores);
        System.out.println("最小值：" + min);

        Collections.sort(scores);
        System.out.println("排序后：" + scores);
        Collections.shuffle(scores);
        System.out.println("乱序后：" + scores);

        Collections.sort(scores);
        // 同Arrays中的binarySearch
        int index = Collections.binarySearch(scores, 85);
        System.out.println("二分查找：" + index + "，找不到，返回-(插入点+1)。");
        index = Collections.binarySearch(scores, 88);
        System.out.println("二分查找：" + index + "，找到，返回索引。");
    }
}
